﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:my="clr-namespace:Microsoft.Live.Controls;assembly=Microsoft.Live.Controls"
    x:Class="MobileNotes.WinPhoneApp.MainPage"
    mc:Ignorable="d"
    d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" >

            <shell:ApplicationBarIconButton IconUri="/Toolkit.Content/ApplicationBar.Add.png" Text="Add" Click="AddNote_Click" />
            <shell:ApplicationBarIconButton IconUri="/Toolkit.Content/ApplicationBar.Select.png" Text="Select" Click="Select_Click" />
            <shell:ApplicationBarIconButton IconUri="/Toolkit.Content/ApplicationBar.Delete.png" Text="Remove" Click="RemoveNote_Click" />

        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>


    <!--Data context is set to sample data above and LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="80"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="MobileNotes.WinPhoneApp" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="MY NOTES" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <my:SignInButton 
            Grid.Row="1" 
            x:Name="SigninButton"
            TextType="SignIn"
            Scopes="wl.signin" 
            Branding="MicrosoftAccount"
            SessionChanged="SignInButton_OnSessionChanged"
        />

        <Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>

            <CheckBox
                Margin="12,0,0,20"
                IsEnabled="{Binding IsUiEnabled}"
                IsChecked="{Binding ShowTodaysNotesOnly, Mode=TwoWay}" 
                Content="Show Notes for the last day only"
            />

            <toolkit:LongListMultiSelector
                Name="MainListBox"
                Grid.Row="1"
                IsEnabled="{Binding IsUiEnabled}"
                ItemsSource="{Binding Notes}"
                SelectionChanged="MainListBox_SelectionChanged"
                IsSelectionEnabledChanged="MainListBox_IsSelectionEnabledChanged"
            >

                <toolkit:LongListMultiSelector.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0,0,0,17">
                            <TextBlock Text="{Binding Text}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                            <TextBlock Text="{Binding TimeCreated}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                        </StackPanel>
                    </DataTemplate>
                </toolkit:LongListMultiSelector.ItemTemplate>

            </toolkit:LongListMultiSelector>
            
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>